import { VueTypeValidableDef, VueTypesInterface, createTypes } from 'vue-types'
import { CSSProperties } from 'vue'

type PropTypes = VueTypesInterface & {
  readonly style: VueTypeValidableDef<CSSProperties>
  readonly array: <T = any>() => VueTypeValidableDef<T[]>
}

const propTypes = createTypes({
  func: undefined,
  bool: undefined,
  string: undefined,
  number: undefined,
  object: undefined,
  integer: undefined
}) as PropTypes

Object.defineProperty(propTypes, 'style', {
  get() {
    return propTypes.oneOfType([String, Object]) as VueTypeValidableDef<CSSProperties>
  }
})

Object.defineProperty(propTypes, 'array', {
  get() {
    return function <T = any>() {
      return propTypes.custom((value) => Array.isArray(value), 'array') as VueTypeValidableDef<T[]>
    }
  }
})

export { propTypes }
